package com.softserveinc.moviedbapp.model;

import android.graphics.Bitmap;

import java.util.ArrayList;
import java.util.List;

public class MovieInfo {

	private int movieId;
	private String overview;
	private String trailerUrl;

	private List<String> backdropImagesUrls;
	private List<String> backdropLocalLocations;
	private List<String> cast;

	private String mCastAsString;

	private boolean screensStored;

	private List<Bitmap> mBackdropBitmaps;

	// constructor
	public MovieInfo() {

	}

	public int getMovieId() {
		return movieId;
	}

	public void setMovieId(final int movieId) {
		this.movieId = movieId;
	}

	public String getOverview() {
		return overview;
	}

	public void setOverview(final String overview) {
		this.overview = overview;
	}

	public List<String> getBackdropImagesUrlsList() {
		return backdropImagesUrls;
	}

	public void setBackdropImagesUrls(final List<String> backdropImagesUrls) {
		this.backdropImagesUrls = backdropImagesUrls;
	}

	public String getTrailerUrl() {
		return trailerUrl;
	}

	public void setTrailerUrl(final String trailerUrl) {
		this.trailerUrl = trailerUrl;
	}

	public String getCast() {

		String castAsString = cast.toString();
		castAsString = castAsString.substring(1, castAsString.length() - 1);

		return castAsString;
	}

	public List<String> getCastList() {
		return cast;
	}

	public void setCast(final List<String> cast) {
		this.cast = cast;
	}

	public String getCastAsString() {
		if (cast != null) {
			setCastAsString(getCast());
		}
		return mCastAsString;
	}

	public void setCastAsString(final String mCastAsString) {
		this.mCastAsString = mCastAsString;
	}

	public boolean isScreensStored() {
		return screensStored;
	}

	public void setScreensStored(final boolean screensStored) {
		this.screensStored = screensStored;
	}

	public List<String> getBackdropLocalLocations() {
		if (backdropLocalLocations != null) {
			return backdropLocalLocations;
		} else {
			backdropLocalLocations = new ArrayList<String>();
			return backdropLocalLocations;
		}

	}

	public void setBackdropLocalLocations(final List<String> backdropLocalLocations) {
		this.backdropLocalLocations = backdropLocalLocations;
	}

//	public int getBackdropImagesUrlSize() {
//		if (backdropImagesUrls != null) {
//			return backdropImagesUrls.size();
//		} else {
//			return 0;
//		}
//	}
//
//	public int getBackdropLocalLocationSize() {
//		if (backdropLocalLocations != null) {
//			if (backdropLocalLocations.size() == backdropImagesUrls.size()) {
//				return 100;
//			} else {
//				return backdropLocalLocations.size();
//			}
//		} else {
//			return 0;
//		}
//	}

	public List<Bitmap> getBackdropBitmaps() {
		if (mBackdropBitmaps != null) {
			return mBackdropBitmaps;
		} else {
			mBackdropBitmaps = new ArrayList<Bitmap>();
			return mBackdropBitmaps;
		}
	}

	public void setBackdropBitmaps(List<Bitmap> mBackdropBitmaps) {
		this.mBackdropBitmaps = mBackdropBitmaps;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append('\n');
		sb.append("MOVIE ID: ");
		sb.append(movieId);
		sb.append('\n');
		sb.append("Overview: ");
		sb.append(overview);
		sb.append('\n');
		sb.append("Cast: ");
		sb.append(mCastAsString);
		sb.append('\n');
		sb.append("Trailer: ");
		sb.append(trailerUrl);
		sb.append('\n');
		sb.append("Backdrops: ");
		sb.append(backdropImagesUrls);
		sb.append('\n');
		sb.append("screensStored: ");
		sb.append(screensStored);

		return sb.toString();
	}

}
